package cn.jbolt.ai.app.controller;

import cn.jbolt.ai.app.entity.AiAppConfig;
import cn.jbolt.ai.app.service.AiAppConfigService;
import cn.jbolt.util.Result;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping("/aiAppConfig")
@Tag(name = "ai应用配置管理Controller")
public class AiAppConfigController {

    @Autowired
    private AiAppConfigService aiAppConfigService;


    @Operation(summary = "修改app的配置", description = "修改app的配置")
    @PostMapping("/updateConfig")
    public Result updateConfig(@RequestBody AiAppConfig aiAppConfig) {
        return aiAppConfigService.update(aiAppConfig.getLinkType(), aiAppConfig.getLinkId(),
                aiAppConfig.getConfigType(), aiAppConfig.getConfigValue());
    }

    @Operation(summary = "根据关联类型,关联id,配置类型三个条件获取相关的配置", description = "根据关联类型,关联id,配置类型三个条件获取相关的配置")
    @GetMapping("/getConfigByCondition")
    public Result getConfigByCondition(String linkType, Long linkId,String configType) {
        return aiAppConfigService.getConfigByCondition(linkType, linkId,configType);
    }
}
